package com.cong.数组越界异常;

public class Demo {
    public static void main(String[] args) {

        System.out.println("开始");
        Demo demo = new Demo();
        demo.test();
        System.out.println("结束");

    }

    public void test(){
        int[] arr={0,2,1};
        /*
ArrayIndexOutOfBoundsException
数组索引越界异常
 */
        //捕获

        try {
            System.out.println(arr[3]);
        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println("你访问的索引不存在");
        }
    }
}
